home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
clang
/
dtk_demo.zip
/
SPLIT_P.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-12
|
3KB
|
107 lines
/* SPLIT_P.C
* demonstrates split_path(), normalize_path()
* and make_path()
* last mod.: 28-AUG-91
*/
#include <STDIO.H>
#include <STDLIB.H>
#include <L_DIR.H>
#include <L_STR.H>
Uchar path[_MAX_PATH_];
Uchar drive[_MAX_DRIVE_];
Uchar dir[_MAX_DIR_];
Uchar file[_MAX_FILE_];
Uchar ext[_MAX_EXT_];
Uchar normal_path[_MAX_PATH_];
/*-----------*/
void main(void)
{
int result;
while ( TRUE )
{
puts("\nEnter path to be split into its components:");
gets_n(path,_MAX_PATH_ - 4);
if ( !*trim(path) )
exit(0);
putchar('\n');
result = split_path(path,drive,dir,file,ext);
if ( result < 0 )
{
switch ( result )
{
case -1:
printf("Invalid path.\n");
break;
case -2:
printf("Invalid drive in path.\n");
break;
case -3:
printf("Disk not present in drive specified in path.\n");
break;
case -4:
printf("Path is NULL or empty.\n");
break;
case -6:
printf("Path is too long.\n");
break;
case -8:
printf("Normalized path is too long.\n");
break;
case -9:
printf("Name exceeds 12 characters.\n");
break;
case -10:
printf("Extension exceeds 3 characters.\n");
break;
case -11:
printf("Base exceeds 8 characters.\n");
break;
case -12:
printf("Base is of zero length.\n");
break;
default:
printf("Unknown error.\n");
}
}
else
{
result = normalize_path(path,normal_path);
printf("Normalized path:\n%s\n",normal_path);
printf("Drive ");
if ( *drive )
printf("= %s\n",drive);
else
printf("not specified.\n");
printf("Directory ");
if ( *dir )
printf("= %s\n",dir);
else
printf("not specified.\n");
printf("Filename ");
if ( *file )
printf("= %s\n",file);
else
printf("not specified.\n");
printf("Extension ");
if ( *ext )
printf("= %s\n",ext);
else
printf("not specified.\n");
printf("Path or file %s.\n",
( result & _PATH_EXISTS_ ?
"exists" : "does not exist" ) );
/* now make the path again */
result = make_path(path,drive,dir,file);
if ( result >= 0 )
printf("Path remade:\n%s\n",path);
else
printf("Error %d when remaking path.\n",result);
}
}
}